package com.mathassistant.client.presenter;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.HasHTML;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;

public class EditorPresenter implements Presenter {

	public interface Display{
		HasClickHandlers getSaveButton();
		HasClickHandlers getCancelButton();
		String getContentHtml();
		void setContentHtml(String content);
		void hideDialog();
		void showDialog();
		Widget asWidget();
	}
	private Display display;
	private HasHTML parent;
	
	public EditorPresenter(HasHTML parent, Display view)
	{
		this.parent = parent;
		this.display = view;
		display.setContentHtml(parent.getHTML());
		bind();
	}
	private void bind() {
		// TODO Auto-generated method stub
		display.getCancelButton().addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				// TODO Auto-generated method stub
				display.hideDialog();
			}
		});
		
		display.getSaveButton().addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				// TODO Auto-generated method stub
				parent.setHTML(display.getContentHtml());
				display.hideDialog();
			}
		});
	}
	@Override
	public void go(HasWidgets container) {
		// TODO Auto-generated method stub

	}

	@Override
	public void go() {
		// TODO Auto-generated method stub

	}

}
